package com.amado.easyui2.util;

import java.util.Optional;

import javax.servlet.http.HttpServletRequest;

import com.amado.easyui2.constant.GlobalConstants;

public class SessionUtils {
	public static String getUserName(HttpServletRequest req) {
//		if(req==null) {
//			return null;
//		}
//		return (String)req.getSession().getAttribute(GlobalConstants.SESSION_USER);
		return Optional.ofNullable(req).map(HttpServletRequest::getSession).map(e->(String)e.getAttribute(GlobalConstants.SESSION_USER)).orElse(null);
	}
}
